package com.javakc.mes.basis.roadway.controller;

import com.javakc.mes.basis.roadway.entity.Roadway;
import com.javakc.mes.basis.roadway.service.RoadwayService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "生产执行基础巷道信息")
@RestController
@RequestMapping("/mes/roadway")
public class RoadwayController {
    @Autowired
    private RoadwayService roadwayService;
    @GetMapping
    @ApiOperation("查询所有巷道区域")
    public List<Roadway> queryAll(){
       return roadwayService.queryAll();
    }
    @ApiOperation("生产执行查询一条数据区域")
    @GetMapping("{id}")
    public Roadway findById(
            @ApiParam(name = "id",value = "主键id",required = true)
            @PathVariable int id){
        return roadwayService.getById(id);
    }
    @PostMapping
    @ApiOperation("生产执行巷道新增区域")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roadwayName",value = "巷道名称",required = true),
            @ApiImplicitParam(name = "roadwayType",value = "巷道类别",required = true),
            @ApiImplicitParam(name = "roadwayLocation",value = "位置",required = true),
            @ApiImplicitParam(name = "grabType",value = "掘进方式",required = true),
            @ApiImplicitParam(name = "supportType",value = "支护方法",required = true),
            @ApiImplicitParam(name = "lithology",value = "岩性",required = true),
            @ApiImplicitParam(name = "designLong",value = "设计总长",required = true),
            @ApiImplicitParam(name = "witch",value = "净宽",required = true),
            @ApiImplicitParam(name = "high",value = "净高",required = true),
            @ApiImplicitParam(name = "grabSpace",value = "掘进断面",required = true),
            @ApiImplicitParam(name = "remark",value = "备注",required = false),
    })
    public void update(@RequestBody @Valid Roadway roadway){
        roadwayService.updateBy(roadway);
    }
    @PostMapping("insert")
    @ApiOperation("生产执行巷道修改区域")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "巷道主键",required = true),
            @ApiImplicitParam(name = "roadwayName",value = "巷道名称",required = true),
            @ApiImplicitParam(name = "roadwayType",value = "巷道类别",required = true),
            @ApiImplicitParam(name = "roadwayLocation",value = "位置",required = true),
            @ApiImplicitParam(name = "grabType",value = "掘进方式",required = true),
            @ApiImplicitParam(name = "supportType",value = "支护方法",required = true),
            @ApiImplicitParam(name = "lithology",value = "岩性",required = true),
            @ApiImplicitParam(name = "designLong",value = "设计总长",required = true),
            @ApiImplicitParam(name = "witch",value = "净宽",required = true),
            @ApiImplicitParam(name = "high",value = "净高",required = true),
            @ApiImplicitParam(name = "grabSpace",value = "掘进断面",required = true),
            @ApiImplicitParam(name = "remark",value = "备注"),
    })
    public void insert(@RequestBody @Valid Roadway roadway){
        roadwayService.insertById(roadway);
    }
    @ApiOperation("生产执行巷道删除区域")
    @DeleteMapping("{id}")
    @ApiImplicitParam(name = "id",value = "主键id",required = true)
    public void deleteById(@PathVariable(name = "id") int id){
        roadwayService.removeById(id);
    }
    @PostMapping("{pageNo}/{pageSize}")
    @ApiOperation("生产执行分页查询区域")
    public Page<Roadway> roadwayPage(
            @ApiParam(name = "pageNo",value = "当前页",required = true)
            @PathVariable int pageNo,
            @ApiParam(name = "pageSize",value = "当前页最大条数",required = true)
            @PathVariable int pageSize){
        return roadwayService.queryPage(pageNo,pageSize);
    }
}
